1. Field of the Invention
The present invention relates to a source code analyzing system and a source code analyzing method.
2. Description of the Related Art
When a processor writes multibyte data in a memory having a byte unit address, there is flexibility with respect to a storage order of data (a variable memory system). As a generally used storage order, there are systems such as a system of sequentially describing bytes from the least significant byte (little Endian system) and a system of sequentially describing bytes from the most significant byte (big Endian system). If it is assumed that an integer in hexadecimal notation is described as 0x1234 by attaching 0x at the head, and a byte sequence arranged continuously on a memory is described as 0x12, 0x23 by separating the byte with a comma sequentially from a byte positioned in a small address, for example, an integer 0x12345678 is described as 0x78, 0x56, 0x34, and 0x12 according to the little-endian system, whereas it is described as 0x12, 0x34, 0x56, and 0x78 according to the big-endian system. Such a storage order of multibyte data is simply referred to as “endianness”.
As it is attempted to read a 4-byte integer value 0x12345678 written in the big-endian system as a 4-byte integer value in the little-endian system, a value 0x78563412 can be acquired. Therefore, if a program written by assuming a processor based on the big-endian system is directly operated in a processor based on the little-endian system, malfunction can occur in read and write of a memory.
The multibyte data can be read and written, assuming a specific storage order, by combining a byte access and a shift operation. In this case, it is possible to describe software that does not depend on endianness of a processing system. However, a decrease in processing speed cannot be avoided due to an increase in the number of memory accesses. Therefore, there are many cases that an endianness dependent program is written while assuming that it is executed by a processor based on specific endianness.
There have been reported some techniques for supporting portability of software to a processor based on different endianness. For example, Japanese Patent Application National Publication No. 2008-523514 discloses a compiling technique for correcting endianness dependent processing by automatically inserting a byte swap command. This technique adopts a policy of finding an assignment statement having incoherent endianness based on endianness information attached to a variable by an operator. As a problem of this technique, an operator who attempts porting software must have sufficient knowledge about the configuration and behavior of the software to be ported. Meanwhile, Japanese Patent Application Laid-Open No. H05-119960 discloses a technique for pointing an endianness dependent part based on a source code of software. According to this technique, a graph structure is created for an assignment relationship of variables of a program to be checked, and it is determined that there can be endianness dependence at a position where a type conversion is performed before and after assignment. In this technique, because of the extraction of the type conversion, it is believed that the detection accuracy deteriorates considerably when endianness information is not attached to a variable.